# --*-- conding:utf-8 --*--
# @Time : 2025/2/3 23:59
# @Author : Mark
# @Email : 17521559996@163.com
# @File : product_template.py
# @Software : PyCharm

from odoo import fields, models,api

class gs_product_template(models.Model):
    _inherit = 'product.template'

    new_variable = fields.Text('新编码')
    fdp_competitive = fields.Char(string="Fdp")
    descrizione_fdp = fields.Text(string="Descrizione Fdp")
    brand_id = fields.Many2one('gs.barnd', string="品牌")
    height_cm = fields.Float(string="高（cm）")
    origin = fields.Char(string="原产地")
    weight_gram = fields.Float(string="克重")
    width_cm = fields.Float(string="宽（cm）")
    length_cm = fields.Float(string="长（cm）")

    @api.model
    def create(self, vals):
        # 确保default_code和barcode字段存在
        if not vals.get('barcode') and vals.get('default_code'):
            vals['barcode'] = vals['default_code']
        # 推荐用 type(self, self) 写法兼容所有继承链
        return super(gs_product_template, self).create(vals)
